home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8542 / 8542.xpi / chrome / lastpass.jar / content / genpw.js < prev    next >
Text File  |  2010-02-14  |  7KB  |  22 lines

  1. var notification=null;function window_load(C,A){C.title=LP.lpgs("Generate Secure Password");C.documentElement.getButton("accept").setAttribute("label",LP.lpgs("Copy"));C.documentElement.getButton("cancel").setAttribute("label",LP.lpgs("Close"));C.documentElement.getButton("extra2").setAttribute("label",LP.lpgs("Generate"));
  2. LP.sr(C,"lpgenpwadv","label","Show Advanced Options");LP.sr(C,"lengthlabel","value","PasswordLength");LP.sr(C,"lpgenpwspecial","label","Special");LP.sr(C,"lpgenpwmindigitslabel","value","MinimumDigitCount");LP.sr(C,"lpgenpwambig","label","Avoid Ambiguous Characters");LP.sr(C,"lpgenpwreqevery","label","Require Every Character Type");
  3. var B=window.arguments;if(B&&B.length>0){notification=B[0]}if(notification){document.getElementById("LPGenPW").getButton("accept").setAttribute("label",LP.lpgs("Accept"));document.getElementById("LPGenPW").getButton("cancel").setAttribute("label",LP.lpgs("Cancel"))}read_prefs();fix_fields();generate_click();
  4. document.getElementById("LPGenPW").getButton("extra2").focus();generate_update_passwordmeter();toggleadv(true)}function generate_update_passwordmeter(){var A=document.getElementById("lpgenpws").value;document.getElementById("passwordmeter").value=LP.calcStrength("",A)}function generate_click(){var D=LP.lpCreatePass(document.getElementById("lpgenpwlen").value,document.getElementById("lpgenpwupper").checked,document.getElementById("lpgenpwlower").checked,document.getElementById("lpgenpwdigits").checked,document.getElementById("lpgenpwspecial").checked,document.getElementById("lpgenpwmindigits").value,document.getElementById("lpgenpwambig").checked,document.getElementById("lpgenpwreqevery").checked);
  5. LP.lpgenpwlist[LP.lpgenpwlist.length]=D;if(LP.lpgenpwlist.length>20){LP.lpgenpwlist.splice(0,LP.lpgenpwlist.length-20)}var B=document.getElementById("lpgenpwspopup");for(var A=B.childNodes.length-1;A>=0;A--){B.removeChild(B.childNodes[A])}for(var A=LP.lpgenpwlist.length-1;A>=0;A--){var C=document.createElement("menuitem");
  6. C.setAttribute("label",LP.lpgenpwlist[A]);B.appendChild(C)}document.getElementById("lpgenpws").value=D;generate_update_passwordmeter()}function copy_click(){LP.lp_generatePasswordComplete(notification,document.getElementById("lpgenpws").value);if(!notification){if(!LP.lpCopyStringToClipboard(document.getElementById("lpgenpws").value)){LP.lpalert_ex(LP.lpgs("ErrorCopyingToClipboard"),window)
  7. }}write_prefs();return true}function close_click(){write_prefs();return true}function fix_fields(){var F=document.getElementById("lpgenpwlen");var G=document.getElementById("lpgenpwupper");var B=document.getElementById("lpgenpwlower");var H=document.getElementById("lpgenpwdigits");var A=document.getElementById("lpgenpwspecial");
  8. var E=document.getElementById("lpgenpwmindigits");var C=document.getElementById("lpgenpwambig");var D=document.getElementById("lpgenpwreqevery");if(G.checked||B.checked||H.checked||A.checked){document.getElementById("lpgenpwlen").disabled=false}else{document.getElementById("lpgenpwlen").disabled=true
  9. }if(H.checked&&(G.checked||B.checked||A.checked)){document.getElementById("lpgenpwmindigitslabel").disabled=false;document.getElementById("lpgenpwmindigits").disabled=false}else{document.getElementById("lpgenpwmindigitslabel").disabled=true;document.getElementById("lpgenpwmindigits").disabled=true}if(G.checked||B.checked||H.checked){document.getElementById("lpgenpwambig").disabled=false
  10. }else{document.getElementById("lpgenpwambig").disabled=true}var J=0;if(G.checked){J++}if(B.checked){J++}if(H.checked){J++}if(A.checked){J++}if(J>=2){document.getElementById("lpgenpwreqevery").disabled=false}else{document.getElementById("lpgenpwreqevery").disabled=true}if(D.checked){F.setAttribute("min",J);
  11. if(parseInt(F.value)<J){F.value=J}else{F.value=F.value}E.setAttribute("min",1);var I=parseInt(F.value)-J+1;E.setAttribute("max",I);if(parseInt(E.value)>I){E.value=I}E.value=E.value}else{F.setAttribute("min",1);F.value=F.value;E.setAttribute("min",0);E.setAttribute("max",F.value);if(parseInt(E.value)>parseInt(F.value)){E.value=F.value
  12. }E.value=E.value}document.getElementById("LPGenPW").getButton("extra2").disabled=G.checked||B.checked||H.checked||A.checked?false:true}function toggleadv(G){var F=(G==null&&document.getElementById("lpgenpwbox1").style.display=="none"?"block":"none");if(G&&document.getElementById("lpgenpwadv").checked){F="block"
  13. }var E=0,D=0,C=0,B=0,A=0;if(F=="none"){E=-1*document.getElementById("lpgenpwbox1").boxObject.height;D=-1*document.getElementById("lpgenpwbox2").boxObject.height;C=-1*document.getElementById("lpgenpwbox3").boxObject.height;B=-1*document.getElementById("lpgenpwbox4").boxObject.height;A=-1*document.getElementById("lpgenpwbox5").boxObject.height
  14. }document.getElementById("lpgenpwbox1").style.display=F;document.getElementById("lpgenpwbox2").style.display=F;document.getElementById("lpgenpwbox3").style.display=F;document.getElementById("lpgenpwbox4").style.display=F;document.getElementById("lpgenpwbox5").style.display=F;if(F!="none"){E=document.getElementById("lpgenpwbox1").boxObject.height;
  15. D=document.getElementById("lpgenpwbox2").boxObject.height;C=document.getElementById("lpgenpwbox3").boxObject.height;B=document.getElementById("lpgenpwbox4").boxObject.height;A=document.getElementById("lpgenpwbox5").boxObject.height}if(!G){window.innerHeight+=E+D+C+B+A}}function read_prefs(){if(LP.lpprefsHasUserValue("genpw_showadv")){document.getElementById("lpgenpwadv").checked=LP.lpprefsGetBoolPref("genpw_showadv")
  16. }if(LP.lpprefsHasUserValue("genpw_passlen")){document.getElementById("lpgenpwlen").value=LP.lpprefsGetIntPref("genpw_passlen")}if(LP.lpprefsHasUserValue("genpw_upper")){document.getElementById("lpgenpwupper").checked=LP.lpprefsGetBoolPref("genpw_upper")}if(LP.lpprefsHasUserValue("genpw_lower")){document.getElementById("lpgenpwlower").checked=LP.lpprefsGetBoolPref("genpw_lower")
  17. }if(LP.lpprefsHasUserValue("genpw_digits")){document.getElementById("lpgenpwdigits").checked=LP.lpprefsGetBoolPref("genpw_digits")}if(LP.lpprefsHasUserValue("genpw_special")){document.getElementById("lpgenpwspecial").checked=LP.lpprefsGetBoolPref("genpw_special")}if(LP.lpprefsHasUserValue("genpw_mindigits")){document.getElementById("lpgenpwmindigits").value=LP.lpprefsGetIntPref("genpw_mindigits")
  18. }if(LP.lpprefsHasUserValue("genpw_ambig")){document.getElementById("lpgenpwambig").checked=LP.lpprefsGetBoolPref("genpw_ambig")}if(LP.lpprefsHasUserValue("genpw_reqevery")){document.getElementById("lpgenpwreqevery").checked=LP.lpprefsGetBoolPref("genpw_reqevery")}}function write_prefs(){LP.lpprefsSetBoolPref("genpw_showadv",document.getElementById("lpgenpwadv").checked);
  19. LP.lpprefsSetIntPref("genpw_passlen",document.getElementById("lpgenpwlen").value);LP.lpprefsSetBoolPref("genpw_upper",document.getElementById("lpgenpwupper").checked);LP.lpprefsSetBoolPref("genpw_lower",document.getElementById("lpgenpwlower").checked);LP.lpprefsSetBoolPref("genpw_digits",document.getElementById("lpgenpwdigits").checked);
  20. LP.lpprefsSetBoolPref("genpw_special",document.getElementById("lpgenpwspecial").checked);LP.lpprefsSetIntPref("genpw_mindigits",document.getElementById("lpgenpwmindigits").value);LP.lpprefsSetBoolPref("genpw_ambig",document.getElementById("lpgenpwambig").checked);LP.lpprefsSetBoolPref("genpw_reqevery",document.getElementById("lpgenpwreqevery").checked);
  21. LP.flush_prefs()};
  22.